package cn.ffcs.bpmpvc.graph;

import java.util.ArrayList;
import java.util.List;

import cn.ffcs.bpmpvc.graph.geom.Rect;


/**
 * 流程节点.
 *
 * @author Lingo
 */
public class Node extends Rect {
	private static final String ICON_PATH="/cn/ffcs/bpmpvc/graph/icons/48";
    /** type. */
    private String type;

    /** name. */
    private String name;
    
    private String id;

    private String parentId;
    
    private String note;
    /** transitions. */
    private List<Transition> transitions = new ArrayList<Transition>();

    /** @return type. */
    public String getType() {
        return type;
    }

    /** @param type String. */
    public void setType(String type) {
        this.type = type;
    }

    /** @return name. */
    public String getName() {
        return name;
    }

    /** @param name String. */
    public void setName(String name) {
        this.name = name;
    }

    /** @return transitions. */
    public List<Transition> getTransitions() {
        return transitions;
    }

    /**
     * 为节点添加一个转移.
     *
     * @param transitionName String
     * @param to String
     */
    public void addTransition(String transitionName, String to) {
        transitions.add(new Transition(transitionName, to));
    }

    /**
     * 获得节点对应的图片路径.
     *
     * @return String
     */
    public String getPicName() {
    	if(type!=null){
    		if (type.equals("start")) {
                return ICON_PATH+"/start_event_empty.png";
            } else if (type.equals("end")) {
                return ICON_PATH+"/end_event_terminate.png";
            } else if (type.equals("end-cancel")) {
                return ICON_PATH+"/end_event_cancel.png";
            } else if (type.equals("end-error")) {
                return ICON_PATH+"/end_event_error.png";
            } else if (type.equals("decision")) {
                return ICON_PATH+"/gateway_exclusive.png";
            }else if (type.equals("fork")) {
                return ICON_PATH+"/gateway_parallel.png";
            }else if (type.equals("join")) {
                return ICON_PATH+"/gateway_parallel.png";
            }
    	}
        return null;
    }

    /** @return String. */
    public String toString() {
        return transitions.toString();
    }

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getParentId() {
		return parentId;
	}

	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}
    
}
